/* MiscCompletionText.m				 
 *
 * For details please read the Docu.
 *
 * For interface-info see the header file. The comments in this file mostly
 * cover only the real implementation details.
 *
 * Written by: 		Thomas Engel
 * Created:    		23.10.1993 (Copyleft)
 * Last modified: 	12.11.1994
 */


#import "MiscCompletionText.h"

@implementation MiscCompletionText

- keyDown:(NXEvent *)event
{
	id	ourDelegate;

	// BUG: We should test the ALT, CMD, etc keys too !
	// BUG: Accept first press only !!!

	if( event->data.key.charSet == NX_ASCIISET &&
		event->data.key.charCode == 0x1b ) 		
	{
		ourDelegate = [self delegate];
	
		// Now if the delegate responds to the textDelegate method we will
		// use that object. This is how we can handle TextFields and
		// Forms too !!.
			
		if( ourDelegate != nil &&
			[ourDelegate respondsTo:@selector(textDelegate)] )
			ourDelegate = [ourDelegate textDelegate];
			
		// Now go ahead...
			
		if( ourDelegate != nil &&
		 	[ourDelegate respondsTo:@selector(textShouldPerformCompletion:)] )
		{
			// Now only on success we will quit right here.

			if( [ourDelegate textShouldPerformCompletion:self] != nil )
				return self;
		}
	}
	// In all the other cases we will try to let our old class do the work.

	return [super keyDown:event];
}

@end


/*
 * History: 13.01.95 Buh
 *			
 *
 * Bugs: - ...
 */